package com.shgbit.tdd.args;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * @author liuyong
 * @date 2020-04-07 14:46
 */
public class Schemas {

    private Map<String, String> schemaMap;

    public Schemas(String schemaStr) {
        HashMap<String, String> schemaMap = new HashMap<>();
        Arrays.asList(schemaStr.split(",")).forEach(schema -> {
            String[] param = schema.split(":");
            schemaMap.put(param[0], param[1]);
        });
        this.schemaMap = schemaMap;
    }

    public String get(String key) {
        return schemaMap.get(key);
    }

    public Set<String> getKeys() {
        return schemaMap.keySet();
    }

    public boolean isKey(String key) {
        return schemaMap.keySet().stream().anyMatch(x -> ("-" + x).equals(key));
    }
}
